const deepClone = (target, hash = new WeakMap()) => {
  if (typeof target !== "object" || target === null) return target;
  if (hash.has(target)) return hash.get(target);

  const cloneTarget = Array.isArray(target) ? [] : {};
  hash.set(target, cloneTarget);

  for (const i in target) {
    if (Object.prototype.hasOwnProperty.call(target, i)) {
      cloneTarget[i] = deepClone(target[i], hash);
    }
  }

  return cloneTarget;
};

const a = { obj: { name: "123" } };
let b = deepClone(a);
a.obj.name = "kaho";
console.log(b);
